﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RPGConsole
{
    public class Title
    {
        public static void Show()
        {
            int cur = 30;
            Console.SetCursorPosition(54, 30);
            Console.Write("> 新的游戏");
            Console.SetCursorPosition(54, 31);
            Console.Write("  读取进度");
            Console.SetCursorPosition(54, 32);
            Console.Write("  退出游戏");

            while (true)
            {
                var key = Console.ReadKey(true).Key;
                if (key == ConsoleKey.DownArrow)
                {
                    if (cur < 32)
                    {
                        Console.SetCursorPosition(54, cur);
                        Console.Write(" ");
                        cur++;
                        Console.SetCursorPosition(54, cur);
                        Console.Write(">");
                    }
                }
                else if (key == ConsoleKey.UpArrow)
                {
                    if (cur > 30)
                    {
                        Console.SetCursorPosition(54, cur);
                        Console.Write(" ");
                        cur--;
                        Console.SetCursorPosition(54, cur);
                        Console.Write(">");
                    }
                }
                else if (key == ConsoleKey.Enter)
                {
                    switch (cur)
                    {
                        case 30:
                            Game.StartNew();
                            break;
                        case 31:
                            Game.Load();
                            break;
                        case 32:
                            System.Environment.Exit(0);
                            break;
                        default:
                            break;
                    }
                }
            }
        }
    }
}
